/*
 * @Author: qianmingtian
 * @Date: 2020-07-14 08:45:42
 * @LastEditors: qianmingtian
 * @LastEditTime: 2020-07-17 09:04:11
 * @FilePath: \qianmingtian.github.io\code\java\MultiThread\ThreadTest.java
 */
package MultiThread;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;

class User extends Thread {
    public User() {
        System.out.println("user thread start");
    }

    @Override
    public void run() {
        // TODO Auto-generated method stub
        for (int i = 0; i < 1000; i++) {
            System.out.println("User -----> " + i);
        }
    }
}

class Animal extends Thread {
    public Animal() {
        System.out.println("animal thread start");
    }

    @Override
    public void run() {
        // TODO Auto-generated method stub
        for (int i = 0; i < 1000; i++) {
            System.out.println("分支annimal -----> " + i);
        }
    }
}

public class ThreadTest {
    public static void main(String[] args) {
        Thread user = new User();

        // start() 瞬间结束
        user.start();

        String tname = user.getName();
        System.out.println(tname);

        // 直接调用run() 需要跳进去
        Thread animal = new Animal();
        // animal.run();

        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("匿名内部");
                Scanner in = new Scanner(System.in);
                String str = in.next();
                in.close();
            }
        });

        // Scanner in = new Scanner(System.in);
        // String str = in.next();
        // in.close();
        t.start();

        try {
            Thread.sleep(1000 * 4);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        for(int i = 0; i< 100 ;i++){
            System.out.println("主 -----> "+ i);
        }


        
    }
}
